import { getBudgetListApi } from '@/api/workflow/budget'

// 获取预算列表hooks
export default function useGetBudgetList() {
  const budgetOptions = ref([])
  const budgetLoading = ref(false)
  const { userInfo } = getUserInfo()

  const fetchGetBudgetList = async (isUse = false) => {
    budgetLoading.value = true
    // 是否使用isUser过滤
    const res = await getBudgetListApi({ isUse, orgId: userInfo.value.orgId })
    if (res.code === '0000') {
      budgetOptions.value = res.data
    }
    budgetLoading.value = false
  }

  fetchGetBudgetList()

  return {
    fetchGetBudgetList,
    budgetOptions,
    budgetLoading
  }
}
